package com.bawei.library_log.logger

import android.content.Context
import android.util.Log
import com.bawei.library_log.ILogger
import com.bawei.library_log.LoggerLevel

/**
 * @Author : 
 * @Time : On 2023/6/20 10:16
 * @Description : LogcatLogger 普通日志输出logger
 */
class LogcatLogger:ILogger {
    private var isDebug = true //是否Debug
    private var TAG = "" //默认TAG
    private var level = LoggerLevel.Debug // 默认日志等级
    private var url = "" //Log存储位置，可以是本地路径 可以是网络路径 可以是Email地址

    private var loggerFormat = "(%s --->%s）" //格式化

    override fun d(tag: String, log: String) {
        if(isDebug && level.ordinal >= LoggerLevel.Debug.ordinal){
            Log.d(TAG, String.format(loggerFormat,tag,log))
        }
    }

    override fun v(tag: String, log: String) {
        if(isDebug && level.ordinal >= LoggerLevel.Verbose.ordinal){
            Log.d(TAG, String.format(loggerFormat,tag,log))
        }
    }

    override fun i(tag: String, log: String) {
        if(isDebug && level.ordinal >= LoggerLevel.Info.ordinal){
            Log.d(TAG, String.format(loggerFormat,tag,log))
        }
    }

    override fun w(tag: String, log: String) {
        if(isDebug && level.ordinal >= LoggerLevel.Warn.ordinal){
            Log.d(TAG, String.format(loggerFormat,tag,log))
        }
    }


    override fun e(tag: String, log: String) {
        if(isDebug && level.ordinal >= LoggerLevel.Error.ordinal){
            Log.d(TAG, String.format(loggerFormat,tag,log))
        }
    }

    override fun setDebug(isDeug: Boolean) {
        this.isDebug = isDebug
    }

    override fun setLogTAG(TAG: String) {
        this.TAG = TAG
    }

    override fun setLoggerLevel(level: LoggerLevel) {
        this.level = level
    }

    override fun setSaveUrl(url: String) {
       this.url = url
    }

    override fun setContext(context: Context?) {

    }
}